function ajax(
    url,
    method = 'GET',
    dataType = 'JSON',
    async = true
){
    return Promise((resolve,reject)=>{
        let xlr = new XMLHttpRequest()
        xlr.open(method,url,async)
        xlr.responseType(dataType)
        xlr.onreadystatechange = () => {
            if(!/^[23]\d{2}/.test(xlr.status)) return
            if(xlr.readyState===4){
                let result = xlr.responseText
                resolve(result)
            }
        }
        xlr.onerror = (err)=>{
            reject(err)
        }

        xlr.send()
    })

}